<template>
  <div class="bg">
      <div class="container">
        <el-container>
            <el-header>
                <el-menu
                    :default-active="activeIndex2"
                    class="el-menu-demo"
                    mode="horizontal"
                    @select="handleSelect"
                    background-color="#545c64"
                    text-color="#fff"
                    active-text-color="#ffd04b">
                    <el-menu-item index="1">首页展示</el-menu-item>
                    <el-submenu index="2">
                        <template slot="title">数据可视化</template>
                        <el-menu-item  @click="cov">大数据</el-menu-item>
                    </el-submenu>
                    <el-menu-item index="4">联系我们</el-menu-item>
                </el-menu>
            </el-header>
            <el-main>
               <el-card shadow="hover" class="box_one">
                </el-card>
                <el-card class="box-card">
                    <!-- 主容器 -->
                    <div class="index_box" ref="myChart" style="width:100%; height:300px"></div>
                </el-card>
            </el-main>
        </el-container>
      </div>
  </div>
</template>


<script>
import echarts from "echarts"
  export default {
    data() {
      return {
        activeIndex: '1',
        activeIndex2: '1',
        option:{
             tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b}: {c} ({d}%)'
    },
    legend: {
        orient: 'vertical',
        left: 10,
        data: ['直达', '营销广告', '搜索引擎', '邮件营销', '联盟广告', '视频广告', '百度', '谷歌', '必应', '其他']
    },
    series: [
        {
            name: '访问来源',
            type: 'pie',
            selectedMode: 'single',
            radius: [0, '30%'],

            label: {
                position: 'inner'
            },
            labelLine: {
                show: false
            },
            data: [
                {value: 335, name: '直达', selected: true},
                {value: 679, name: '营销广告'},
                {value: 1548, name: '搜索引擎'}
            ]
        },
        {
            name: '访问来源',
            type: 'pie',
            radius: ['40%', '55%'],
            label: {
                formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                backgroundColor: '#eee',
                borderColor: '#aaa',
                borderWidth: 1,
                borderRadius: 4,
                // shadowBlur:3,
                // shadowOffsetX: 2,
                // shadowOffsetY: 2,
                // shadowColor: '#999',
                // padding: [0, 7],
                rich: {
                    a: {
                        color: '#999',
                        lineHeight: 22,
                        align: 'center'
                    },
                    // abg: {
                    //     backgroundColor: '#333',
                    //     width: '100%',
                    //     align: 'right',
                    //     height: 22,
                    //     borderRadius: [4, 4, 0, 0]
                    // },
                    hr: {
                        borderColor: '#aaa',
                        width: '100%',
                        borderWidth: 0.5,
                        height: 0
                    },
                    b: {
                        fontSize: 12,
                        lineHeight: 20
                    },
                    per: {
                        color: '#eee',
                        backgroundColor: '#334455',
                        padding: [1, 3],
                        borderRadius: 5
                    }
                }
            },
            data: [
                {value: 335, name: '直达'},
                {value: 310, name: '邮件营销'},
                {value: 234, name: '联盟广告'},
                {value: 135, name: '视频广告'},
                {value: 1048, name: '百度'},
                {value: 251, name: '谷歌'},
                {value: 147, name: '必应'},
                {value: 102, name: '其他'}
            ]
        }
    ]
        }
 
      };
    },
    methods: {
      handleSelect(key, keyPath) {
        console.log(key, keyPath);
      },
      cov() {
          this.$router.push('/?zzz=1')
      },
      weather() {
          console.log(2)
      },
      drawLine() {
          // 初始化图表
          //console.log(this.$refs.myChart)
          let myChart = echarts.init(this.$refs.myChart)
          // 配置参数
          myChart.setOption(this.option)
      }
    },
    // 等待dom的加载
    mounted() {
        // 画图
        this.drawLine()
    }
  }
</script>

<style scoped>
.el-card sapn {
}
  .el-main {
    margin-top: 20px;
    background-color: #E9EEF3;
    opacity: 0.8;
    text-align: center;
    line-height: 160px;
    height: 100%;
    padding: 0;
    position: relative;
  }
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  .el-header {
      padding: 0;
  }
  .el-container {
      height: 100% !important;
  }
  .container {
      height: 100% !important;
  }
  .bg {
      height: 100%;
      background-size: 100% 100%;
      background: url('../assets/1.jpg');
  }
  .box-card {
    width: 650px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 350px;
    box-shadow: 10px 10px 5px #2D4A31 !important;
    border-radius: 4%;
  }
  .index_box {
      margin:0 auto;
  }
  .box_one {
      height: 60px !important;
      box-shadow: 10px 10px 5px #2D4A31 !important;
      text-align: center;
      line-height: 60px !important;
  }
  .box_one .el-card__body {
      height: 30px !important;
      padding: 0;
      margin: 0;
      
  }
</style>